package com.gujia.atomic.bank;

public class AtomicCounterTest implements Runnable {

    private AtomicBank bank;

    public AtomicCounterTest(AtomicBank bank) {
        this.bank = bank;
    }

    @Override
    public void run() {
        while (true){
            this.bank.getMoney(1);
        }

    }


    public static void main(String[] args){
        AtomicBank bank = new AtomicBank(100);

        AtomicCounterTest test1 = new AtomicCounterTest(bank);
        AtomicCounterTest test2 = new AtomicCounterTest(bank);

        AtomicCounterTest test3 = new AtomicCounterTest(bank);
        AtomicCounterTest test4 = new AtomicCounterTest(bank);

        new Thread(test1).start();
        new Thread(test2).start();
        new Thread(test3).start();
        new Thread(test4).start();

    }
}
